import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig(config => {
    let base = '/'
    switch (config.mode) {
        case 'production':
            base = '/'
            break
        case 'chrome':
            base='/chrome/'
            break
        case 'score':
            base='/score/'
            break
        default:
            base='/'
    }
    console.log(base)
    return {
        plugins: [
            vue(),
        ],
        base,
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url)),
                '@module-base': fileURLToPath(new URL('./src/module-base', import.meta.url)),
                '@module-chrome': fileURLToPath(new URL('./src/module-chrome', import.meta.url)),
                '@module-demo': fileURLToPath(new URL('./src/module-demo', import.meta.url)),
                '_c': fileURLToPath(new URL('./src/components', import.meta.url)),
                // 'monaco-editor': 'monaco-editor/esm/vs/editor/editor.api.js'
            }
        },
        optimizeDeps: {
            include: [
                `monaco-editor/esm/vs/language/json/json.worker`,
                `monaco-editor/esm/vs/language/css/css.worker`,
                `monaco-editor/esm/vs/language/html/html.worker`,
                `monaco-editor/esm/vs/language/typescript/ts.worker`,
                `monaco-editor/esm/vs/editor/editor.worker`
            ],
        },
    }

})
